StringUtils

Properties

Functions

Link copied to clipboard
Link copied to clipboard

Encode the given byte array using base64 and return the result as a string.

Encode the given string as a (utf8) byte array and then encode that using base64 and return the result as a string. Note: Only available as of build 528

Link copied to clipboard

Return a String with the first letter capitalized.

Link copied to clipboard
open fun combineWords(fields: List<String>?): String?

Concatenate all of the strings in the given list with spaces between each but skipping null or empty strings. You can pass a List with entries such as "field1", null, "field3", "", "field4" and will get back "field1 field3 field4".

fun combineWords(fields: List<String>?, avoidRepeating: Boolean): String?

Concatenate all of the strings in the given list with spaces between each but skipping null or empty strings. You can pass a List with entries such as "field1", null, "field3", "", "field4" and will get back "field1 field3 field4". If the avoidRepeating flag is true then this will not add any fields that already exist in the combined string so far.

Link copied to clipboard
fun concatenatePaths(basepath: String?, relativePath: String?): String

Combine the given base path and the given relative path, either or both of which may be empty. This is a basic concatenation with a slash in between non-empty paths. It does not handle parent path references such as ".."

Link copied to clipboard

Performs a conversion from the given string to an encoded version that can be used as a file/URL name. This is new as of Moneydance build 325.

Link copied to clipboard
fun countFields(str: String?, delimiter: Char): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

This method decodes a URL parameter that has special characters %encoded

Link copied to clipboard
fun doNothing()
Link copied to clipboard
Link copied to clipboard
fun encodeHex(buf: ByteArray?, breaklines: Boolean): String
Link copied to clipboard

This method encodes a URL parameter with non-URL-safe characters being %-encoded

Link copied to clipboard
fun fieldIndex(str: String, delimiter: Char, n: Int): String
Link copied to clipboard
fun fillLeft(str: String?, width: Int, fillChar: Char): String
Link copied to clipboard
fun fillRight(str: String?, width: Int, fillChar: Char): String
Link copied to clipboard
fun formatFixedDecimals(value: String, decimalChar: Char, numDecimals: Int): String

Formats the given double 0..1.00 as a percentage with the specified number of decimal digits showing.

Link copied to clipboard
fun formatMinDecimals(value: String, decimalChar: Char, numDecimals: Int): String

Formats the given double 0..1.00 as a percentage with the specified number of decimal digits showing as a minimum, there could be more.

Link copied to clipboard
fun formatPercentage(value: Double, decimalChar: Char, forceDecimal: Boolean = false): String

Formats the given double 0..1.00 as a percentage with either zero (if an even percentage) or two decimal digits showing. If forceDecimal is true, digits after the decimal point will be displayed regardless of whether it is an even percentage or not.

Link copied to clipboard
fun formatRate(rate: BigDecimal, decimalChar: Char): String

Format a BigDecimal

fun formatRate(rate: Double, decimalChar: Char, maxDecPlaces: Int? = null, fillZeroes: Boolean = false): String

Format a Double with a maximum of maxDecimalPlaces decimal places, while truncating any trailing zeroes, and ensuring that there are at least minDecPlaces displayed

Link copied to clipboard
fun formatShortRate(rate: Double, decimalChar: Char): String
Link copied to clipboard
fun formatURLParameters(parameters: Map<String?, String?>, includeQuestionMarkIfNonEmpty: Boolean): String?

Builds a string contained the given URL parameters encoded as percent-escaped-utf8 strings

Link copied to clipboard

Return a decimal number formatter that is appropriate for displaying the given amount. This will return a formatter with a smaller number of decimal places and less precision for very large values, and a formatter with higher precision (more decimal places) for very small numbers.

Link copied to clipboard

Returns the extension, if any, on the given file name. Returns an empty string if there was no extension and null if the given filename was null.

Link copied to clipboard
Link copied to clipboard
fun getNLengthString(width: Int, fillChar: Char): String
Link copied to clipboard

Convenience method that Returns the given string or the empty string if the given string is null

Link copied to clipboard
fun guessDecimalType(currencyString: String): Char
Link copied to clipboard
fun isAllNumber(str: String, allowLeadingMinusSign: Boolean): Boolean
Link copied to clipboard
fun isBlank(candidate: String?): Boolean

Null safe check for a String with nothing but whitespace characters.

Link copied to clipboard
Link copied to clipboard
fun isEmpty(candidate: String?): Boolean

Null safe check for "" (empty string).

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun join(strings: List<String>?, joinString: String): String

Concatenate all strings in the given list with the joinString between them

Link copied to clipboard

Returns true if the given parameter looks vaguely like a valid email address. No guarantees though.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun parseDecimalWithException(stringValue: String, decimalChar: Char): BigDecimal
Link copied to clipboard
fun parseDouble(val: String, decimalChar: Char): Double
fun parseDouble(stringValue: String?, defaultVal: Double, decimalChar: Char): Double
Link copied to clipboard
fun parseDoubleWithException(stringValue: String, decimalChar: Char): Double
Link copied to clipboard
Link copied to clipboard
fun parseFraction(fraction: String, decimalChar: Char): Double

Parse a fraction from a string - ie "1/5". Returns 1 if there was an error in the format

Link copied to clipboard
Link copied to clipboard
fun parseRate(rateStr: String, decimalChar: Char): Double
fun parseRate(rateStr: String, defaultRate: Double, decimalChar: Char): Double
Link copied to clipboard
fun parseURLParameters(parameterString: String, map: MutableMap<String?, String?>)
Link copied to clipboard
Link copied to clipboard
fun replaceAll(str: String, toReplace: String, replaceWith: String?): String

Replace one or more tokens inside another string with a value.

Link copied to clipboard

Returns a substring whole length is guaranteed to be no longer than limit or the given string itself if its length is less than limit.

Link copied to clipboard
Link copied to clipboard
fun split(str: String, splitChar: Char): Array<String>
Link copied to clipboard
fun splitIntoList(str: String, splitChar: Char): List<String>
Link copied to clipboard

Returns the filename passed as argument without extension

Link copied to clipboard

Remove leading and trailing quotes or white space from a string

Link copied to clipboard

Strip all characters that should not appear in a filename (including path characters)

Link copied to clipboard
fun stripNonNumbers(str: String, decimalChar: Char): String
Link copied to clipboard
fun stripPath(filename: String?): String?

Returns the file name with any path stripped from the beginning. This is available as of build 812

Link copied to clipboard
fun truncateHead(s: String, limit: Int, prefix: String): String

Returns a string that is guaranteed to be withing 'limit' characters by truncating the beginning of the string, if necessary.

Link copied to clipboard